package dse;

import java.util.Properties;

import dse.modules.Assigner;
import dse.modules.BloomFilterGenerator;
import dse.modules.BloomFilterRefreshDecisionMaker;
import dse.modules.CacheDecisionMaker;
import dse.modules.RequestUpdateEventScheduler;
import dse.modules.ClusterGenerator;
import dse.modules.CommunicationCostCalculator;
import dse.modules.DataObjectAccessRanker;
import dse.modules.DataObjectGenerator;
import dse.modules.MessageSizeCalculator;
import dse.modules.NetworkTopologyGenerator;
import dse.modules.NodeBandwidthAssigner;
import dse.modules.NodeEventScheduler;
import dse.modules.RequestEventScheduler;
import dse.modules.ShareRequestDecisionMaker;

public class Modules {
	private ModuleLoader loader;
	
	private NetworkTopologyGenerator networkTopologyGenerator;
	private CommunicationCostCalculator costCalculator;
	private ClusterGenerator clusterGenerator;
	private NodeEventScheduler nodeEventScheduler;
	private DataObjectGenerator dataObjectsGenerator;
	private DataObjectAccessRanker dataObjectAccessRanker;
	private RequestEventScheduler requestEventScheduler;
	private BloomFilterGenerator bloomFilterGenerator;
	private ShareRequestDecisionMaker shareRequestDecisionMaker;
	private BloomFilterRefreshDecisionMaker bloomFilterRefreshDecisionMaker;
	private CacheDecisionMaker cacheDecisionMaker;
	private Assigner shareAssigner; 
	private MessageSizeCalculator messageSizeCalculator;
	private NodeBandwidthAssigner nodeBandwithAssigner;
	private RequestUpdateEventScheduler requestUpdateEventScheduler;
	
	
	
	public Modules (ExperimentConfiguration sysSettings, Properties props)
	throws DseException
	{
		loader = new ModuleLoader (sysSettings, props);
		
		networkTopologyGenerator = (NetworkTopologyGenerator)loader.loadModule(
				"topology-generator", 
				NetworkTopologyGenerator.class
				);
		costCalculator = (CommunicationCostCalculator)loader.loadModule(
				"communication-cost-calculator", 
				CommunicationCostCalculator.class
				);
		clusterGenerator = (ClusterGenerator)loader.loadModule(
				"cluster-generator", 
				ClusterGenerator.class
				);
		nodeEventScheduler = (NodeEventScheduler)loader.loadModule(
				"node-event-scheduler", 
				NodeEventScheduler.class
				);
		dataObjectsGenerator = (DataObjectGenerator)loader.loadModule(
				"data-object-generator", 
				DataObjectGenerator.class
				);
		dataObjectAccessRanker = (DataObjectAccessRanker)loader.loadModule(
				"access-ranker", 
				DataObjectAccessRanker.class
				);
		requestEventScheduler = 
				(RequestEventScheduler)loader.loadOptionalModule(
					"request-scheduler", 
					RequestEventScheduler.class
					);
		bloomFilterGenerator = (BloomFilterGenerator)loader.loadModule(
				"bloom-filter-generator", 
				BloomFilterGenerator.class
				);
		shareRequestDecisionMaker = (ShareRequestDecisionMaker)
			loader.loadModule(
				"share-request-decision-maker", 
				ShareRequestDecisionMaker.class
				);
		bloomFilterRefreshDecisionMaker = (BloomFilterRefreshDecisionMaker)
			loader.loadOptionalModule(
				"bloom-filter-refresh-decision-maker", 
				BloomFilterRefreshDecisionMaker.class
				);
		cacheDecisionMaker = (CacheDecisionMaker)loader.loadOptionalModule(
				"cache-decision-maker", 
				CacheDecisionMaker.class
				);
		shareAssigner = (Assigner)loader.loadModule(
				"assigner",
				Assigner.class
				);
		messageSizeCalculator = (MessageSizeCalculator)loader.loadModule(
				"message-size-calculator",
				MessageSizeCalculator.class
				);
		nodeBandwithAssigner = (NodeBandwidthAssigner)loader.loadModule(
				"bandwidth-assigner",
				NodeBandwidthAssigner.class
				);
		requestUpdateEventScheduler = (RequestUpdateEventScheduler)
				loader.loadOptionalModule(
						"request-update-event-scheduler",
						RequestUpdateEventScheduler.class
						);
	}


	public BloomFilterGenerator bloomFilterGenerator () {
		return this.bloomFilterGenerator;
	}


	public BloomFilterRefreshDecisionMaker bloomFilterRefreshDecisionMaker () {
		return this.bloomFilterRefreshDecisionMaker;
	}


	public CacheDecisionMaker cacheDecisionMaker () {
		return this.cacheDecisionMaker;
	}


	public ClusterGenerator clusterGenerator () {
		return this.clusterGenerator;
	}


	public CommunicationCostCalculator costCalculator () {
		return this.costCalculator;
	}


	public DataObjectAccessRanker dataObjectAccessRanker () {
		return this.dataObjectAccessRanker;
	}


	public DataObjectGenerator dataObjectsGenerator () {
		return this.dataObjectsGenerator;
	}

	public NetworkTopologyGenerator networkTopologyGenerator () {
		return this.networkTopologyGenerator;
	}


	public NodeEventScheduler nodeEventScheduler () {
		return this.nodeEventScheduler;
	}


	public RequestEventScheduler requestEventScheduler () {
		return this.requestEventScheduler;
	}


	public ShareRequestDecisionMaker shareRequestDecisionMaker () {
		return this.shareRequestDecisionMaker;
	}


	public Assigner assigner () {
		return this.shareAssigner;
	}


	public MessageSizeCalculator messageSizeCalculator () {
		return this.messageSizeCalculator;
	}
	
	
	public NodeBandwidthAssigner bandwidthAssigner () {
		return this.nodeBandwithAssigner;
	}


	public RequestUpdateEventScheduler cachingRequestUpdateScheduler () {
		return this.requestUpdateEventScheduler;
	}
}
